package events.shapes;

import java.awt.BasicStroke;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JComboBox;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import snazzysprites.SnazzySprites;
import gui.SnazzySpritesGUI;
import shapes.SnazzyShapeType;
import state.SnazzySpritesState;
import state.SnazzySpritesStateManager;

/**
 * This handler responds to when the user requests to
 * start drawing a line.
 * 
 * @author Andrew Gratta
 * @version 1.0
 */
public class LineStrokeSelectionHandler implements ItemListener
{
    /**
     * When the user requests to change the line thickness, we'll need
     * to notify the data manager, since it manages the 
     * shape in progress. It will update the gui as needed
     * as well.
     * 
     * @param e The Event Object.
     */
    @Override
    public void itemStateChanged(ItemEvent e) {
        JComboBox source = (JComboBox)e.getSource();
        SnazzySprites singleton = SnazzySprites.getSnazzySprites();
        SnazzySpritesStateManager poseurStateManager = singleton.getStateManager();
        if (poseurStateManager.getMode() == SnazzySpritesState.SHAPE_SELECTED_STATE)
        {
            SnazzySpritesGUI gui = singleton.getGUI();
            poseurStateManager.getSelectedShape().setOutlineThickness(new BasicStroke(source.getSelectedIndex()+1));
            poseurStateManager.refreshState();
        }
    }
}